public class BankCard {
    private String name;
    private String account;
    private String passWord;
    private int balance;
    private String color;

    public BankCard() {
    }

    public BankCard(String name, String account, String passWord, int balance, String color) {
        this.name = name;
        this.account = account;
        this.passWord = passWord;
        this.balance = balance;
        this.color = color;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    public String getPassWord() {
        return passWord;
    }

    public void setPassWord(String passWord) {
        this.passWord = passWord;
    }

    public int getBalance() {
        return balance;
    }

    public void setBalance(int balance) {
        this.balance = balance;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    // 取钱
    public boolean withDraw(int money) {
        if (money <= balance) {
            balance -= money;
            return true;
        }
        return false;
    }

    // 存钱
    public boolean saveMoney(int money) {
        if (money > 0) {
            balance += money;
            return true;
        }
        return false;
    }

    /**
     * @param bankCard 对方账号
     * @param money    转账的金额
     * @return
     */
    public boolean transFerAccounts(BankCard bankCard, int money) {
        if (bankCard == null) {
            return false;
        }
        if (money <= 0 || money > balance) {
            return false;
        }

        this.balance -= money;
        bankCard.balance += money;
        return true;

    }

}

